package com.zl.project.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zl.project.dao.suppmesgPagingDao;
import com.zl.project.pojo.supplymesg;
import com.zl.project.pojo.suppmesgPaging;
import com.zl.project.service.Impl.supplymesgServiceImpl;
/**
 * 资源主页面控制器
 * @author 12642
 *
 */
@Controller
@RequestMapping("/rc")
public class resourceController {
	
	@Autowired
	private supplymesgServiceImpl si;
	
	@Autowired
	private suppmesgPagingDao smp;
	
	@RequestMapping("paging") //资源页面分页
	public String suppmesgPaging(suppmesgPaging sp,Model model) {
		if(sp.getPage()==null || "".equals(sp.getPage())) {//当page为空,那么page为1
			sp.setPage(1);
		}
		System.out.println("程序运行");
		sp.setPagecount(smp.PagingCount(sp));//将条件查询到的数据数量传到sp中
		List<suppmesgPaging> mesgList = smp.suppmesgPaging(sp);
		System.out.println(smp.PagingCount(sp)+"???");
		model.addAttribute("mesgList",mesgList);//查询到的数据
		model.addAttribute("condition", sp);//传进来的条件
//		for(int i=0;i<mesgList.size();i++) {
//			System.out.println(mesgList.get(i).getConname()+"???");
//		}
		return "resource";
	}
	
	@RequestMapping("resourcejsp")
	public String resourcejsp() {
		return "forward:paging";
	}
}
